"""

@File:ego_user_api.py
@Datetime:2022/11/13 15:55
@Author:wangt
@Desc:
"""
import requests

from config import BASE_URL

# 定义User用户接口
class EgoUserApi(object):
    def __init__(self):
        self.get_token_url = f"{BASE_URL}/api/v1/token/user"
        self.verify_token_url = f"{BASE_URL}/api/v1/token/verify"
    # 获取token接口
    def get_token(self,code):
        data = {"code":code}
        resp = requests.post(self.get_token_url,json=data)
        return resp
    # 验证token接口
    def verify_token(self,token):
        data = {"token":token}
        resp = requests.post(self.verify_token_url,json=data)
        return resp

if __name__ == '__main__':
    eu = EgoUserApi()
    code = {"code": "033nhY000GgPUO1gSA2005sZgV1nhY0B"}
    resp = eu.get_token(code)
    json_data = resp.json()
    token = json_data.get("token")
    print(token)